<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Fetch profiler data</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="luasandbox.getpeakmemoryusage.html">« LuaSandbox::getPeakMemoryUsage</a></li>
      <li style="float: right;"><a href="luasandbox.getversioninfo.html">LuaSandbox::getVersionInfo »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.luasandbox.html">LuaSandbox</a></li>
    <li>Fetch profiler data</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="luasandbox.getprofilerfunctionreport" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">LuaSandbox::getProfilerFunctionReport</h1>
  <p class="verinfo">(PECL luasandbox &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">LuaSandbox::getProfilerFunctionReport</span> &mdash; <span class="dc-title">Fetch profiler data</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-luasandbox.getprofilerfunctionreport-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>LuaSandbox::getProfilerFunctionReport</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$units</code><span class="initializer"> = LuaSandbox::SECONDS</span></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   For a profiling instance previously started by
   <span class="methodname"><a href="luasandbox.enableprofiler.html" class="methodname">LuaSandbox::enableProfiler()</a></span>, get a
   report of the cost of each function.
  </p>
  <p class="para">
   The measurement unit used for the cost is determined by the
   <var class="varname">$units</var> parameter:
  </p>
  <p class="para">
   <dl>
    
     <dt>
<strong><code>LuaSandbox::SAMPLES</code></strong></dt>

     <dd>
<p class="para">Measure in number of samples.</p></dd>

    
    
     <dt>
<strong><code>LuaSandbox::SECONDS</code></strong></dt>

     <dd>
<p class="para">Measure in seconds of CPU time.</p></dd>

    
    
     <dt>
<strong><code>LuaSandbox::PERCENT</code></strong></dt>

     <dd>
<p class="para">Measure percentage of CPU time.</p></dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-luasandbox.getprofilerfunctionreport-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">units</code></dt>

    <dd>

     <p class="para">
      Measurement unit constant.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-luasandbox.getprofilerfunctionreport-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns profiler measurements, sorted in descending order, as an associative
   <span class="type">array</span>. Keys are the Lua function names (with source file and line
   defined in angle brackets), values are the measurements as <span class="type">int</span>
   or <span class="type">float</span>.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    On Windows, this function always returns an empty array. On operating systems that do
    not support <strong><code>CLOCK_THREAD_CPUTIME_ID</code></strong>, such as FreeBSD
    and Mac OS X, this function will report the elapsed wall-clock time, not
    CPU time.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 examples" id="refsect1-luasandbox.getprofilerfunctionreport-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3436">
    <p><strong>示例 #1 Profiling Lua code</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;create&nbsp;a&nbsp;new&nbsp;LuaSandbox<br /></span><span style="color: #0000BB">$sandbox&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">LuaSandbox</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">//&nbsp;Start&nbsp;the&nbsp;profiler<br /></span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">enableProfiler</span><span style="color: #007700">(&nbsp;</span><span style="color: #0000BB">0.01&nbsp;</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;...&nbsp;Execute&nbsp;some&nbsp;Lua&nbsp;code&nbsp;here&nbsp;...<br /><br />//&nbsp;Fetch&nbsp;the&nbsp;profiler&nbsp;data<br /></span><span style="color: #0000BB">$data&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$sandbox</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProfilerFunctionReport</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


</div></div></div></body></html>